﻿using System;
using System.ComponentModel.DataAnnotations;
using Viettel.VOFFICE.DAO.Models;

namespace Viettel.VOFFICE.Web.Models
{
    public class FlowModel : BaseModel
    {
        public FlowModel() { }
        public FlowModel(Flow flow)
        {
            Id = flow.Id;
            Name = flow.Name;
            Description = flow.Description;
            IsActive = flow.IsActive;
            IsCommon = flow.IsCommon;
            DocTypeId = flow.DocTypeId;
            CreatedAt = flow.CreatedAt;
            UpdatedAt = flow.UpdatedAt;
            CreatorId = flow.CreatorId;
            IsReady = flow.IsReady;
            if (DocTypeId != null && DocTypeId != 0)
            {
                DocTypeName = flow.DocumentType.Name;
            }

            DepartmentId = flow.DepartmentId;
            IsDefault = flow.IsDefault;
            if (DepartmentId != null && DepartmentId != 0)
            {
                DepartmentName = flow.v_Department.Name;
            }
        }

        public int Id { get; set; }
        [Required(ErrorMessageResourceType = typeof(Resources.Resources), ErrorMessageResourceName = "region")]
        public string Name { get; set; }
        [Required(ErrorMessageResourceType = typeof(Resources.Resources), ErrorMessageResourceName = "region")]
        public string Description { get; set; }
        public bool? IsActive { get; set; }
        public bool? IsCommon { get; set; }
        public bool? IsReady { get; set; }
        public int? DocTypeId { get; set; }
        public int? DepartmentId { get; set; }
        public bool? IsDefault { get; set; }
        public DateTime CreatedAt { get; set; }
        public DateTime UpdatedAt { get; set; }
        public Guid? CreatorId { get; set; }

        public string DocTypeName { get; set; }
        public string DepartmentName { get; set; }
    }
}